//
//  NetworkingViewController.m
//  LOL_JewelBox
//
//  Created by dllo on 15/5/6.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "NetworkingViewController.h"
#import "AFNetworking.h"
@interface NetworkingViewController ()

@end

@implementation NetworkingViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"网络连接已断开,请检查您的网络" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
                    [alert show];
                    [alert release];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = YES;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(VIEWWIDTH / 3.0, VIEWHEIGHT/3.0, 100, 30);
    [button setTitle:@"刷新" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(refreshAction:) forControlEvents:UIControlEventTouchUpInside];
    button.layer.borderWidth = 0.5;
    button.layer.borderColor = [[UIColor blackColor] CGColor];
    button.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:button];
    self.tabBarController.tabBar.hidden = YES;


}
 -(void)refreshAction:(id)sender
{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    [manager GET:@"http://iphone.mengbaby.com//mengmengda/index?udid=DAAADB5A-537C-4010-B95D-10C47E8DF556&urid=1061647&ctid=1038&token=KXczZVq-DF5ltNMcQVt8tGMXDwZNbBl5YxNXqXysMP8RdUphBKcOk8dRTGcvrunhIlBvdwJwKnYMCZEKL2A3Sw&lat=0.000000&lng=0.000000&conn=wifi&v=2.3.0&lang=zh-Hans&width=320&height=568&account=DAAADB5A-537C-4010-B95D-10C47E8DF556&dist=5&dosv=8.1&device=iPhone5,3" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        if (responseObject != nil) {
            [self.navigationController popViewControllerAnimated:YES];
            self.tabBarController.tabBar.hidden = NO;
            self.navigationController.navigationBar.hidden = NO;
        }else{
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"刷新失败,请检查网络重试" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
            [alert show];
            [alert release];
        }

    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"刷新失败,请检查网络重试" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alert show];
        [alert release];


    }];






}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
